home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
api_shar
/
share.doc
< prev
next >
Wrap
Text File
|
1989-01-26
|
3KB
|
71 lines
Shared Memory/Data Example Programs
The sample programs SHAREA and SHAREB demonstrate how to share memory
among multiple processes. What's being shared is data, not code. To
better understand shared memory, read pages 16-1 thru 16-3 of Chapter 16:
Memory Management in the DESQview API Reference Manual. To read about
sharing program code, see the "Shared Programs" section beginning on
page 16-4.
Shared data can be of any type or structure. SHAREA and SHAREB
demonstrate how programs can share integer, string or structured data.
As distributed, these programs are set up to share string data. To sample
the sharing of integer data, comment out the string-related code, then
uncomment the integer-related code. For record/struct data, uncomment the
record/struct-related code.
The following table specifies the commenting conventions used:
Data Type C Source Pascal Source
------------- ---------------- ----------------
integer /*i* code *i*/ (*i* code *i*)
string /*s* code *s*/ (*s* code *s*)
record/struct /*r* code *r*/ (*r* code *r*)
The following files are contained within the APISHARE.ARC file:
SHARE.DOC This document
SHAREA.C C source code to be compiled/linked into SHAREA.EXE
SHAREB.C C source code to be compiled/linked into SHAREB.EXE
SHAREA.PAS Pascal source code to be compiled/linked into SHAREA.EXE
SHAREB.PAS Pascal source code to be compiled/linked into SHAREB.EXE
SA-PIF.DVP PIF file to be installed on the Open Window menu
SHAREB.DVP PIF file called by SHAREA.EXE that loads SHAREB.EXE
Normally, a process allocates "system memory" from within its
"process memory" pool. Such system memory is not shareable among other
processes. If your goal is to share a global block of data among
multiple processes, an alternate method of allocating system memory
is needed.
Placing a single asterisk (*) in the PIF file's "Shared Memory Pathname"
field enables such an allocation scheme. Thereafter, the process' request
for system memory will be allocated as "shared memory", taken from the
lower end of available conventional memory. Such shared/system memory
is always accessible by all processes. And, if your application makes
a call to api_getmem, system memory will be allocated from the shared
memory pool, instead of the normal process memory pool.
Api_getmem also returns a pointer to where the allocated memory/data
resides. All other processes requiring access to the shared memory need
only be told where the memory begins (i.e., a pointer to it). In the
example programs, SHAREA (the process that makes the call to allocate
shared memory) mails this information to SHAREB (the process that needs
to be informed where the shared memory resides).
Note that only one application needs to put the asterisk (*) in its PIF;
the one that makes the call to api_getmem. No other application is
required to use the asterisk (*); no other process is required to make
another call to api_getmem.
For further information contact:
Quarterdeck Office Systems
150 Pico Boulevard
Santa Monica, CA 90405
Voice: (213) 392-9851 or (213) 392-9701
BBS: (213) 396-3904 or (213) 392-2278
Fax: (213) 399-3802